"""
@name : 2-1.线程的使用
@author : wenyao
@projectname: sanchuanglianxi
"""
import requests
import time
from dec import cost
from threading import Thread

def get_content(url):
    text = requests.get(url).content
    time.sleep(0.5)
    print("get content")

@cost
def main():
    urls = ["https://www.baidu.com/",
            "https://www.baidu.com/",
            "https://www.baidu.com/",
            "https://www.baidu.com/",
            "https://www.baidu.com/",
            "https://www.baidu.com/"]
    for url in urls:
        #创建线程
        #target   ---》指定要传入的方法名字
        #args  --》指定方法要传入的参数  元组类型
        t = Thread(target=get_content,args=(url,))
        #启动线程， 进入就绪状态
        t.start()

        #get_content(url)

if __name__ == "__main__":
    main()
    print("end.......")